package com.happy.main.controller;

import com.happy.main.config.redis.Message;
import com.happy.main.config.redis.Subscriber;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: happy-shopping-op
 * @description: redis队列controller
 * @author: taoxinhuan
 * @create: 2020-04-26 20:45
 **/
@RestController
@RequestMapping
@Slf4j
public class ReidsController {
    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private Subscriber subscriber;

    @GetMapping(value = "pub/{id}")
    public String pubMsg(@PathVariable String id) {
        Message message=new Message(id,"这是第"+id+"个生产者");
        redisTemplate.opsForList().leftPush("queue", message);
        return "success";
    }
}
